package com.csc.contact.checkbill.controller;


import com.csc.contact.checkbill.kafkaconfig.KafkaProducer;
import com.csc.contact.checkbill.service.*;
import com.csc.contact.checkbill.task.MyTask;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/checkbill")
@Api(value = "checkbill", description = "对账接口")
@ApiResponses(value = {@ApiResponse(code = 200, message = "请求已完成"), @ApiResponse(code = 201, message = "资源成功被创建"), @ApiResponse(code =
        400, message = "请求中有语法问题，或不能满足请求"), @ApiResponse(code = 401, message = "未授权客户机访问数据"), @ApiResponse(code = 403, message =
        "服务器接受请求，但是拒绝处理"), @ApiResponse(code = 404, message = "服务器找不到给定的资源；文档不存在"), @ApiResponse(code = 500, message = "服务器出现异常")})

public class CheckBillController {

    @Resource(name = "reconciliationservice")
    private ReconciliationServiceImpl reconciliationService;

    @Resource(name = "urpchargeinfoService")
    private UrpChargeinfoServiceImpl urpChargeinfoService;
    /*@Autowired*/
    @Resource(name = "checklogService")
    private CheckLogServiceImpl checklogService;

    @Resource(name = "checkdiffservice")
    private CheckDiffServiceImpl checkDiffService;

    @Resource(name = "urpprovinceservice")
    private UrpProvinceinfoServiceImpl urpProvinceinfoService;

    @Resource(name = "kafkaConfig")
    private KafkaProducer kafkaProducer;


    @ApiOperation(value = "对账文件入库", notes = "对账文件入库", response = String.class)
    @RequestMapping(value = "/test", method = RequestMethod.POST)
    public String checkbill() {
        /**
         * 测试
         */
        String time = "00:00:00";
        /*new MyTask().fixedRate(time, new ReadFileFromFTPTask(reconciliationService, urpChargeinfoService, checklogService,
                checkDiffService));*/
        new ReadFileFromFTPTask(reconciliationService, urpChargeinfoService, checklogService, checkDiffService, urpProvinceinfoService,
                kafkaProducer).run();
        return "test";
    }
}
